﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace FRL.DebtChased.WorkflowEditor
{

	/// <summary>
	/// Declaration of DayPickerWnd class
	/// Window to pick day to insert action into planner at
	/// </summary>
	public partial class DayPickerWnd : ChildWindow
	{

		/////////////////////////////////////////////////////////////
		// Attributes

		private static int m_iSelectedDay = 0;
		public static int SelectedDay
		{
			get { return m_iSelectedDay; }
		}

		/////////////////////////////////////////////////////////////
		// Construction

		public DayPickerWnd()
		{

			// Initialize resources
			InitializeComponent();

			// Set events for day buttons
			StackPanel[] stacks = new StackPanel[4] {stack0, stack1, stack2, stack3};
			foreach(StackPanel stack in stacks)
			{
				foreach(UIElement el in stack.Children)
				{
					if(el is Button)
						(el as Button).Click+=new RoutedEventHandler(NumberButton_Click);
				}
			}

		}

		/////////////////////////////////////////////////////////////
		// Event handlers

		private void CancelButton_Click(object sender, RoutedEventArgs e)
		{

			// Close dialog
			this.DialogResult = false;

		}

		private void NumberButton_Click(object sender, RoutedEventArgs e)
		{

			// Get the number clicked
			int iDay = int.Parse((sender as Button).Content.ToString());

			// Update static
			m_iSelectedDay = iDay;

			// Close dialog
			this.DialogResult = true;

		}

	}

}

